<template>
  <div class="freeBackWrapper">
        <!--<x-input placeholder="标题"></x-input>
        <x-textarea :max="200" name="description" placeholder="描述"></x-textarea>-->
        <div class="top-des">
            亲爱的小主，使用我们的服务，有什么意见和建议，请赐教。伦家会在24小时内进行认真回复，还会给优质反馈的用户提供礼物呢~
        </div>
        <div class="middle-input">
          <group>
            <x-textarea :value.sync="freebackContent" name="description" placeholder="请输入反馈内容" :rows="8"></x-textarea>
          </group>
          <group>
            <x-input :value.sync="name" title="联系姓名" placeholder="联系人姓名" type="text"></x-inpu>
          </group>
          <group>
            <x-input :value.sync="phone" title="联系方式" placeholder="联系人手机号" type="text"></x-input>
          </group>
        </div>
        <div class="submit-btn">
          <x-button type="warn" v-show="submitStatus" @click="submitFreeBack" >提交</x-button>
        </div>
  </div>
</template>
<script>
  import { Group,  XTextarea, XInput, XButton } from './../../components'
  var Global = require("./../../commons/js/Global.js")
   var MyRequest = require('./../../commons/js/MyRequest.js')
  export default {
    data () {
      return {
        submitStatus: true,
        freebackContent: "",
        phone: "",
        name: ""
      }
    },
    components: {
      Group,
      XTextarea,
      XInput,
      XButton
    },
    methods: {
      submitFreeBack () {
        if(!this.freebackContent) {
          Global.showToast('反馈内容不能为空', this)
          return
        }
        if(!this.freebackContent) {
          Global.showToast('联系人姓名不能为空', this)
          return
        }
        if(!(/^1[34578]\d{9}$/.test(this.phone))) {
          Global.showToast('请检查手机号格式', this)
          return
        }
        var data = {
            action:"feedback",
            content:this.freebackContent,
            mobile:this.phone,
            name:this.name
        }
        MyRequest.MyGetWithToast("FeedBack", this, function(result, that) {
          console.log(result)
          Global.showToast('反馈成功', that)
          history.go(-1)
        }, data);
      }
    },
    created: function () {
      Global.closeLoading()
    }
  }
</script>
